package com.example.securitydemo.controller;

import com.example.securitydemo.pojo.User;
import com.example.securitydemo.pojo.result.ResponseResult;
import com.example.securitydemo.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author Fausto
 * @Date 2022/9/4 13:48
 * @Comment 登录控制层
 * @Version 1.0
 */
@Api(tags = "登录控制器",description = "登录控制器")
@RestController
public class LoginController {

    @Resource
    private LoginService loginService;

    /**
     * 登录
     * @param user
     * @return
     */
    @ApiOperation(value = "用户登录")
    @PostMapping("/login")
    public ResponseResult login(@RequestBody User user){
        return loginService.login(user);
    }

    /**
     * 退出登录
     * @return
     */
    @ApiOperation(value = "退出登录")
    @PostMapping("/logoff")
    public ResponseResult logout(){
        return loginService.logout();
    }
}
